package com.ng.application.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * @Author: Ng
 * @Date: 2024/4/10
 * @Versopn: 1.0.0
 * @Description:
 */
public class SPUtils {

    /**
     * 获取 SharedPreferences
     * @param context getActivity() || Context
     * @param var 源
     * @return preferences
     */
    public SharedPreferences getSP(Context context, String var) {
        return context.getSharedPreferences(var, Context.MODE_PRIVATE);
    }

    /**
     * 设置 SharedPreferences
     * @param context getActivity() || Context
     * @param var 源
     * @param key key
     * @param value value
     */
    public void setSP(Context context, String var, String key, String value) {
        SharedPreferences.Editor editor = context.getSharedPreferences(var, Context.MODE_PRIVATE).edit();
        editor.putString(key, value);
        editor.apply();
    }

}
